//
//  ScrollViewImageItem.swift
//  Scroller_swift
//
//  Created by CarlsonLee on 2020/4/22.
//  Copyright © 2020 CarlsonLee. All rights reserved.
//

import UIKit
import Kingfisher

class ScrollViewImageItem: ScrollerViewItem {
    var imgView: UIImageView?
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initSubviews()
    }
    
    private func initSubviews() {
        imgView = UIImageView(frame: self.bounds)
        contentView.addSubview(imgView!)
    }
    
    override func setData(_ urlName: String) {
        if urlName.hasPrefix("http") {
            imgView?.kf.setImage(with: URL(string: urlName)!)
        }else{
            self.imgView?.image = UIImage(named: urlName);
        }
    }
}
